/*
* @Author: obsidian
* @Date:   2016-03-01 10:49:08
* @Last Modified by:   obsidian
* @Last Modified time: 2016-04-22 09:12:34
*/

#include "menu_steer.h"
#include "../lcd_global.h"
#include "../lcd.h"
#include "module/steer/steer.h"

static void menu_steer_init(void *parg);

struct Item steer_i[MAX_ITEM_NUM] = 
{
    //ctx               id  flag   isint color int float pos
    {.ctx = "ccr",      .id = 1,  .ctx_len = 3,  .flag = FILE,  .value_type = INTEGER, .p_value = 0,                          .func_enter = nop, input,  nop,    nop},
    {.ctx = "midvl",    .id = 2,  .ctx_len = 5,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&steer.midvalue,    .func_enter = nop, input,  nop,    nop},    
    {.ctx = "ulimit",   .id = 3,  .ctx_len = 6,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&steer.limit[0],    .func_enter = nop, input,  nop,    nop},    
    {.ctx = "llimit",   .id = 4,  .ctx_len = 6,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&steer.limit[1],    .func_enter = nop, input,  nop,    nop},
    {.ctx = "ratio",    .id = 5,  .ctx_len = 5,  .flag = FILE,  .value_type = FLOAT, .p_value = (void *)&steer.ratio,         .func_enter = nop, input,  nop,    nop},    
    {.ctx = "status",   .id = 6,  .ctx_len = 6,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&steer.status,      .func_enter = nop, input,  nop,    nop},    

};

struct Node steer_n = 
{
    // .itemnum            = sizeof(steer_i) / sizeof(steer_i[0]),
    // .page_num           = (unsigned short)sizeof(steer_i) / sizeof(steer_i[0])/PAGE_SIZE,
    .page_index         = 0,  //page_index
    .node_id            = 3,  //node_id
    .p_item             = steer_i,
    .position           = {0, 0},
    .parent             = &control_n,
    .child              = {0},
    .init               = menu_steer_init,
};
static void menu_steer_init(void *parg)
{
    unsigned char i = 0;
    for(i = 0;i < MAX_ITEM_NUM;i ++)
    {
        if(steer_i[i].ctx[0] == 0){break;}
        steer_n.itemnum ++;
    }
    steer_n.page_num = steer_n.itemnum / PAGE_SIZE;

    steer_n.p_item[0].p_value = (void *)steer.CCRx;
    steer_n.save = steer.save;
}
